package com.example.com.daervideo.popuwindow;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;

import com.example.com.daervideo.R;

/**
 * Created by i7-1 on 2018/12/10.
 */

public class ZuanNumPpWindow extends PopupWindow {
    private final Context context;
    private int ID;
    private final RecyclerView recyclerView;
    private final ZAdapter zAdapter;

    public ZuanNumPpWindow(Context context) {
        this.context = context;
        final View mMenuView = LayoutInflater.from(context).inflate(R.layout.popuwindow_zuan_num, null);
        recyclerView = (RecyclerView) mMenuView.findViewById(R.id.zuan_rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        zAdapter = new ZAdapter();


        //设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
        //适配虚拟键
        this.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        //设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);
        //设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x30000000); //android:background="#30000000"
        //设置SelectPicPopupWindow弹出窗体的背景
        this.setBackgroundDrawable(dw);
        recyclerView.setAdapter(zAdapter);
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    private class ZAdapter extends RecyclerView.Adapter {
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View inflate = LayoutInflater.from(context).inflate(R.layout.item_zuan, parent, false);

            return new AHolder(inflate);
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        }

        @Override
        public int getItemCount() {
            return 10;
        }
    }

    private class AHolder extends RecyclerView.ViewHolder {
        public AHolder(View inflate) {
            super(inflate);
        }
    }
}
